#pragma once
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#ifndef CHR_INDEX2GENE_NAME_H
#define CHR_INDEX2GENE_NAME_H

class CGene
{
public:
    CGene(void);
    ~CGene(void);
    CGene(string name, unsigned int startIndex);

    string name;
    unsigned int startIndex;
    bool operator<(const CGene &other) const;  // compare the start index
    bool operator==(const CGene &other) const; // return true if the name is the same
};

/*
 * This class is designed to translate the chromosome index to a gene index
 * by binary search the "sorted" gene vector. For each gene in the record,
 * the name and it's starting chromosome index is kept
 */
class ChrIndex2GeneName
{
public:
    ChrIndex2GeneName(void);
    virtual ~ChrIndex2GeneName(void);
    int insert(string name, unsigned int startIndex);
    int  getGeneId(unsigned int chrIndex);
    int  getGeneLength(int geneId, int chrLength);
    // translate the chromosome index to the gene it locates and the corresponding position in the gene
    CGene query(unsigned int chrIndex);
    vector<CGene> table;
};
#endif

